﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 学生绩效
{
    delegate void ShowUIMSG(string xcor,string ycor);

    public partial class FormXueye : Form
    {
        ShowUIMSG invokeMethod;
        private string _choice;
        private bool mouseDownFlag = false;

        System.Drawing.Point frmLocation = new System.Drawing.Point(0, 0);
        private void UpdateUI(string xcor,string ycor)
        {
            this.label1.Text = xcor + " " + ycor;
        }
        Form1 frmmain;

        public string Choice { get => _choice; set => _choice = value; }

        public FormXueye(Form1 frm)
        {
            frmmain = frm;
            this.Choice = frm.Choicename;
            InitializeComponent();
            this.MouseDown += FormXueye_MouseDown;
            this.MouseMove += FormXueye_MouseMove;
            this.MouseUp += FormXueye_MouseUp;
            var refreshimg = System.IO.Path.GetFullPath(@"pictures/RefImg.png");
            var reimg = System.IO.Path.GetFullPath(@"pictures/return.png");
            var detailmg = System.IO.Path.GetFullPath(@"pictures/detail.png");

            this.label3.Image = Image.FromFile(refreshimg);
            this.label2.Image = Image.FromFile(detailmg);
            this.label4.Image = Image.FromFile(reimg);
            this.StartPosition = FormStartPosition.CenterScreen;
            this.Width = Screen.PrimaryScreen.WorkingArea.Width;
            this.Height = Screen.PrimaryScreen.WorkingArea.Height;
        }

        private void FormXueye_MouseUp(object sender, MouseEventArgs e)
        {
            mouseDownFlag = false;
            this.Left += (e.X - frmLocation.X);
            this.Top += (e.Y - frmLocation.Y);
        }

        private void FormXueye_MouseMove(object sender, MouseEventArgs e)
        {
            if (mouseDownFlag)
            {
                this.Left += (e.X - frmLocation.X);
                this.Top += (e.Y - frmLocation.Y);
            }
            label1.Text = string.Format("{0} {1}",e.X, e.Y);
        }

        private void FormXueye_MouseDown(object sender, MouseEventArgs e)
        {
            frmLocation = e.Location;
            mouseDownFlag = true;
        }
        private void DrawGroupName(string huaxiangname,int offsetx,int offsety)
        {
            var g = this.CreateGraphics();
            Rectangle rectoshowname = new Rectangle(0+offsetx, 420+offsety, 200, 25);
            g.FillRectangle(new SolidBrush(Color.Red), rectoshowname);
            g.DrawString("            " + huaxiangname, new Font("微软雅黑", 14), Brushes.White, rectoshowname);
        }
        private void label3_Click(object sender, EventArgs e)
        {
            //backgroundWorker1.DoWork += BackgroundWorker1_DoWork;
            //backgroundWorker1.ProgressChanged += BackgroundWorker1_ProgressChanged;
            //backgroundWorker1.RunWorkerCompleted += BackgroundWorker1_RunWorkerCompleted;
            //backgroundWorker1.RunWorkerAsync();
            //Option1_ExecProcess();
            if (frmmain.Choicename == "zhiye")
            {
                DrawMethodNew();
            }
            else if (frmmain.Choicename == "xueye")
            {
                DrawMethod();
            }
            

        }

        private void DrawMethod()
        {
            int xoffset = 200;
            int yoffset = 150;
            string[] msgs = new string[11];

            #region 颜色与序号字典
            Color blue = Color.FromArgb(33, 105, 211);
            Color green = Color.FromArgb(52, 164, 113);
            Color orange = Color.FromArgb(255, 192, 0);
            Color red = Color.FromArgb(255, 0, 0);
            Dictionary<int, Color> keyValuePairs = new Dictionary<int, Color>();
            keyValuePairs.Add(0, blue);
            keyValuePairs.Add(1, green);
            keyValuePairs.Add(2, orange);
            keyValuePairs.Add(3, red);
            #endregion
            #region 角一
            double corner1_1 = 0.00;
            ExcelOpe.ReadSpeCell(4, 7, ref corner1_1);
            double corner1_2 = 0.00;
            ExcelOpe.ReadSpeCell(5, 7, ref corner1_2);
            double corner1_3 = 0.00;
            ExcelOpe.ReadSpeCell(6, 7, ref corner1_3);
            double corner1_4 = 0.00;
            ExcelOpe.ReadSpeCell(7, 7, ref corner1_4);
            double[] corner1 = new double[] { corner1_1, corner1_2, corner1_3, corner1_4 };
            double[] corer1copy = (double[])corner1.Clone();
            Array.Sort(corer1copy);
            Array.Reverse(corer1copy);
            //应该是求原始数据的第0个在排序之后的索引
            int ind1_0 = Array.IndexOf(corer1copy, corner1[0]);
            int ind1_1 = Array.IndexOf(corer1copy, corner1[1]);
            int ind1_2 = Array.IndexOf(corer1copy, corner1[2]);
            int ind1_3 = Array.IndexOf(corer1copy, corner1[3]);
            #endregion
            #region 角二
            ExcelOpe.ReadSpeCell(4, 11, ref corner1_1);
            ExcelOpe.ReadSpeCell(5, 11, ref corner1_2);
            ExcelOpe.ReadSpeCell(6, 11, ref corner1_3);
            ExcelOpe.ReadSpeCell(7, 11, ref corner1_4);
            double[] corner2 = new double[] { corner1_1, corner1_2, corner1_3, corner1_4 };
            double[] corer2copy = (double[])corner2.Clone();
            Array.Sort(corer2copy);
            Array.Reverse(corer2copy);
            //应该是求原始数据的第0个在排序之后的索引
            int ind2_0 = Array.IndexOf(corer2copy, corner2[0]);
            int ind2_1 = Array.IndexOf(corer2copy, corner2[1]);
            int ind2_2 = Array.IndexOf(corer2copy, corner2[2]);
            int ind2_3 = Array.IndexOf(corer2copy, corner2[3]);
            #endregion
            #region 角三
            ExcelOpe.ReadSpeCell(4, 15, ref corner1_1);
            ExcelOpe.ReadSpeCell(5, 15, ref corner1_2);
            ExcelOpe.ReadSpeCell(6, 15, ref corner1_3);
            ExcelOpe.ReadSpeCell(7, 15, ref corner1_4);
            double[] corner3 = new double[] { corner1_1, corner1_2, corner1_3, corner1_4 };
            double[] corer3copy = (double[])corner3.Clone();
            Array.Sort(corer3copy);
            Array.Reverse(corer3copy);
            //应该是求原始数据的第0个在排序之后的索引
            int ind3_0 = Array.IndexOf(corer3copy, corner3[0]);
            int ind3_1 = Array.IndexOf(corer3copy, corner3[1]);
            int ind3_2 = Array.IndexOf(corer3copy, corner3[2]);
            int ind3_3 = Array.IndexOf(corer3copy, corner3[3]);
            #endregion
            #region 角四
            ExcelOpe.ReadSpeCell(4, 19, ref corner1_1);
            ExcelOpe.ReadSpeCell(5, 19, ref corner1_2);
            ExcelOpe.ReadSpeCell(6, 19, ref corner1_3);
            ExcelOpe.ReadSpeCell(7, 19, ref corner1_4);
            double[] corner4 = new double[] { corner1_1, corner1_2, corner1_3, corner1_4 };
            double[] corer4copy = (double[])corner4.Clone();
            Array.Sort(corer4copy);
            Array.Reverse(corer4copy);
            //应该是求原始数据的第0个在排序之后的索引
            int ind4_0 = Array.IndexOf(corer4copy, corner4[0]);
            int ind4_1 = Array.IndexOf(corer4copy, corner4[1]);
            int ind4_2 = Array.IndexOf(corer4copy, corner4[2]);
            int ind4_3 = Array.IndexOf(corer4copy, corner4[3]);
            #endregion
            #region 角中
            ExcelOpe.ReadSpeCell(4, 24, ref corner1_1);
            ExcelOpe.ReadSpeCell(5, 24, ref corner1_2);
            ExcelOpe.ReadSpeCell(6, 24, ref corner1_3);
            ExcelOpe.ReadSpeCell(7, 24, ref corner1_4);
            double[] corner5 = new double[] { corner1_1, corner1_2, corner1_3, corner1_4 };
            double[] corer5copy = (double[])corner5.Clone();//这个是用来得到颜色的分布
            double[] corer5score = (double[])corner5.Clone();//这个是用来得到具体的成绩

            Array.Sort(corer5copy);
            Array.Reverse(corer5copy);
            //应该是求原始数据的第0个在排序之后的索引
            int ind5_0 = Array.IndexOf(corer5copy, corner5[0]);
            int ind5_1 = Array.IndexOf(corer5copy, corner5[1]);
            int ind5_2 = Array.IndexOf(corer5copy, corner5[2]);
            int ind5_3 = Array.IndexOf(corer5copy, corner5[3]);
            #endregion

            
            //需求组的四个顶角排名，与角中的分数
            msgs[0] = (ind1_0 + 1).ToString() + "/4";
            msgs[1] = "角一";
            msgs[2] = (ind2_0 + 1).ToString() + "/4";
            msgs[3] = "角二";
            msgs[4] = (ind3_0 + 1).ToString() + "/4";
            msgs[5] = "角三";
            msgs[6] = (ind4_0 + 1).ToString() + "/4";
            msgs[7] = "角四";
            msgs[8] = "学习绩效";
            msgs[9] = "综合完成分";
            msgs[10] = corer5score[0].ToString();
            DrawHuaxiang(new Color[] {
                keyValuePairs[ind1_0],//角一
                keyValuePairs[ind2_0],//角二
                keyValuePairs[ind3_0],//角三
                keyValuePairs[ind4_0],//角四
                keyValuePairs[ind5_0] },//角中
                xoffset + 250 * 0, yoffset, msgs);
            //方案组的四个顶角排名，与角中的分数
            msgs[0] = (ind1_1 + 1).ToString() + "/4";
            msgs[1] = "角一";
            msgs[2] = (ind2_1 + 1).ToString() + "/4";
            msgs[3] = "角二";
            msgs[4] = (ind3_1 + 1).ToString() + "/4";
            msgs[5] = "角三";
            msgs[6] = (ind4_1 + 1).ToString() + "/4";
            msgs[7] = "角四";
            msgs[8] = "学习绩效";
            msgs[9] = "综合完成分";
            msgs[10] = corer5score[1].ToString();
            //方案组
            DrawHuaxiang(new Color[] {
                keyValuePairs[ind1_1],
                keyValuePairs[ind2_1],
                keyValuePairs[ind3_1],
                keyValuePairs[ind4_1],
                keyValuePairs[ind5_1] }, xoffset + 250 * 1, yoffset, msgs);

            //装调组的四个顶角排名，与角中的分数
            msgs[0] = (ind1_2 + 1).ToString() + "/4";
            msgs[1] = "角一";
            msgs[2] = (ind2_2 + 1).ToString() + "/4";
            msgs[3] = "角二";
            msgs[4] = (ind3_2 + 1).ToString() + "/4";
            msgs[5] = "角三";
            msgs[6] = (ind4_2 + 1).ToString() + "/4";
            msgs[7] = "角四";
            msgs[8] = "学习绩效";
            msgs[9] = "综合完成分";
            msgs[10] = corer5score[2].ToString();
            //装调组
            DrawHuaxiang(new Color[] {
                keyValuePairs[ind1_2],
                keyValuePairs[ind2_2] ,
                keyValuePairs[ind3_2] ,
                keyValuePairs[ind4_2] ,
                keyValuePairs[ind5_2] ,}, xoffset + 250 * 2, yoffset, msgs);

            //验证组的四个顶角排名，与角中的分数
            msgs[0] = (ind1_3 + 1).ToString() + "/4";
            msgs[1] = "角一";
            msgs[2] = (ind2_3 + 1).ToString() + "/4";
            msgs[3] = "角二";
            msgs[4] = (ind3_3 + 1).ToString() + "/4";
            msgs[5] = "角三";
            msgs[6] = (ind4_3 + 1).ToString() + "/4";
            msgs[7] = "角四";
            msgs[8] = "学习绩效";
            msgs[9] = "综合完成分";
            msgs[10] = corer5score[3].ToString();
            //验证组
            DrawHuaxiang(new Color[] {
                keyValuePairs[ind1_3],
                keyValuePairs[ind2_3],
                keyValuePairs[ind3_3],
                keyValuePairs[ind4_3],
                keyValuePairs[ind5_3]},
                xoffset + 250 * 3, yoffset, msgs);
            DrawGroupName("需求组", xoffset + 250 * 0, yoffset);
            DrawGroupName("方案组", xoffset + 250 * 1, yoffset);
            DrawGroupName("装调组", xoffset + 250 * 2, yoffset);
            DrawGroupName("验证组", xoffset + 250 * 3, yoffset);
        }private void DrawMethodNew()
        {
            int xoffset = 200;
            int yoffset = 150;
            string[] msgs = new string[11];

            #region 颜色与序号字典
            Color blue = Color.FromArgb(33, 105, 211);
            Color green = Color.FromArgb(52, 164, 113);
            Color orange = Color.FromArgb(255, 192, 0);
            Color red = Color.FromArgb(255, 0, 0);
            Dictionary<int, Color> keyValuePairs = new Dictionary<int, Color>();
            keyValuePairs.Add(0, blue);
            keyValuePairs.Add(1, green);
            keyValuePairs.Add(2, orange);
            keyValuePairs.Add(3, red);
            #endregion
            #region 角一
            double corner1_1 = 0.00;
            ExcelOpe.ReadSpeCell(4, 6, ref corner1_1,"");
            double corner1_2 = 0.00;
            ExcelOpe.ReadSpeCell(5, 6, ref corner1_2,"");
            double corner1_3 = 0.00;
            ExcelOpe.ReadSpeCell(6, 6, ref corner1_3,"");
            double corner1_4 = 0.00;
            ExcelOpe.ReadSpeCell(7, 6, ref corner1_4,"");
            double[] corner1 = new double[] { corner1_1, corner1_2, corner1_3, corner1_4 };
            double[] corer1copy = (double[])corner1.Clone();
            Array.Sort(corer1copy);
            Array.Reverse(corer1copy);
            //应该是求原始数据的第0个在排序之后的索引
            int ind1_0 = Array.IndexOf(corer1copy, corner1[0]);
            int ind1_1 = Array.IndexOf(corer1copy, corner1[1]);
            int ind1_2 = Array.IndexOf(corer1copy, corner1[2]);
            int ind1_3 = Array.IndexOf(corer1copy, corner1[3]);
            #endregion
            #region 角二
            ExcelOpe.ReadSpeCell(4, 11, ref corner1_1,"");
            ExcelOpe.ReadSpeCell(5, 11, ref corner1_2,"");
            ExcelOpe.ReadSpeCell(6, 11, ref corner1_3,"");
            ExcelOpe.ReadSpeCell(7, 11, ref corner1_4,"");
            double[] corner2 = new double[] { corner1_1, corner1_2, corner1_3, corner1_4 };
            double[] corer2copy = (double[])corner2.Clone();
            Array.Sort(corer2copy);
            Array.Reverse(corer2copy);
            //应该是求原始数据的第0个在排序之后的索引
            int ind2_0 = Array.IndexOf(corer2copy, corner2[0]);
            int ind2_1 = Array.IndexOf(corer2copy, corner2[1]);
            int ind2_2 = Array.IndexOf(corer2copy, corner2[2]);
            int ind2_3 = Array.IndexOf(corer2copy, corner2[3]);
            #endregion
            #region 角三
            ExcelOpe.ReadSpeCell(4, 15, ref corner1_1,"");
            ExcelOpe.ReadSpeCell(5, 15, ref corner1_2,"");
            ExcelOpe.ReadSpeCell(6, 15, ref corner1_3,"");
            ExcelOpe.ReadSpeCell(7, 15, ref corner1_4,"");
            double[] corner3 = new double[] { corner1_1, corner1_2, corner1_3, corner1_4 };
            double[] corer3copy = (double[])corner3.Clone();
            Array.Sort(corer3copy);
            Array.Reverse(corer3copy);
            //应该是求原始数据的第0个在排序之后的索引
            int ind3_0 = Array.IndexOf(corer3copy, corner3[0]);
            int ind3_1 = Array.IndexOf(corer3copy, corner3[1]);
            int ind3_2 = Array.IndexOf(corer3copy, corner3[2]);
            int ind3_3 = Array.IndexOf(corer3copy, corner3[3]);
            #endregion
            #region 角四
            ExcelOpe.ReadSpeCell(4, 19, ref corner1_1,"");
            ExcelOpe.ReadSpeCell(5, 19, ref corner1_2,"");
            ExcelOpe.ReadSpeCell(6, 19, ref corner1_3,"");
            ExcelOpe.ReadSpeCell(7, 19, ref corner1_4,"" );
            double[] corner4 = new double[] { corner1_1, corner1_2, corner1_3, corner1_4 };
            double[] corer4copy = (double[])corner4.Clone();
            Array.Sort(corer4copy);
            Array.Reverse(corer4copy);
            //应该是求原始数据的第0个在排序之后的索引
            int ind4_0 = Array.IndexOf(corer4copy, corner4[0]);
            int ind4_1 = Array.IndexOf(corer4copy, corner4[1]);
            int ind4_2 = Array.IndexOf(corer4copy, corner4[2]);
            int ind4_3 = Array.IndexOf(corer4copy, corner4[3]);
            #endregion
            #region 角中
            ExcelOpe.ReadSpeCell(4, 23, ref corner1_1,""); 
            ExcelOpe.ReadSpeCell(5, 23, ref corner1_2,"");
            ExcelOpe.ReadSpeCell(6, 23, ref corner1_3,"");
            ExcelOpe.ReadSpeCell(7, 23, ref corner1_4,"");
            double[] corner5 = new double[] { corner1_1, corner1_2, corner1_3, corner1_4 };
            double[] corer5copy = (double[])corner5.Clone();//这个是用来得到颜色的分布
            double[] corer5score = (double[])corner5.Clone();//这个是用来得到具体的成绩

            Array.Sort(corer5copy);
            Array.Reverse(corer5copy);
            //应该是求原始数据的第0个在排序之后的索引
            int ind5_0 = Array.IndexOf(corer5copy, corner5[0]);
            int ind5_1 = Array.IndexOf(corer5copy, corner5[1]);
            int ind5_2 = Array.IndexOf(corer5copy, corner5[2]);
            int ind5_3 = Array.IndexOf(corer5copy, corner5[3]);
            #endregion

            
            //需求组的四个顶角排名，与角中的分数
            msgs[0] = (ind1_0 + 1).ToString() + "/4";
            msgs[1] = "角一";
            msgs[2] = (ind2_0 + 1).ToString() + "/4";
            msgs[3] = "角二";
            msgs[4] = (ind3_0 + 1).ToString() + "/4";
            msgs[5] = "角三";
            msgs[6] = (ind4_0 + 1).ToString() + "/4";
            msgs[7] = "角四";
            msgs[8] = "职业绩效";
            msgs[9] = "综合完成分";
            msgs[10] = corer5score[0].ToString();
            DrawHuaxiang(new Color[] {
                keyValuePairs[ind1_0],//角一
                keyValuePairs[ind2_0],//角二
                keyValuePairs[ind3_0],//角三
                keyValuePairs[ind4_0],//角四
                keyValuePairs[ind5_0] },//角中
                xoffset + 250 * 0, yoffset, msgs);
            //方案组的四个顶角排名，与角中的分数
            msgs[0] = (ind1_1 + 1).ToString() + "/4";
            msgs[1] = "角一";
            msgs[2] = (ind2_1 + 1).ToString() + "/4";
            msgs[3] = "角二";
            msgs[4] = (ind3_1 + 1).ToString() + "/4";
            msgs[5] = "角三";
            msgs[6] = (ind4_1 + 1).ToString() + "/4";
            msgs[7] = "角四";
            msgs[8] = "职业绩效";
            msgs[9] = "综合完成分";
            msgs[10] = corer5score[1].ToString();
            //方案组
            DrawHuaxiang(new Color[] {
                keyValuePairs[ind1_1],
                keyValuePairs[ind2_1],
                keyValuePairs[ind3_1],
                keyValuePairs[ind4_1],
                keyValuePairs[ind5_1] }, xoffset + 250 * 1, yoffset, msgs);

            //装调组的四个顶角排名，与角中的分数
            msgs[0] = (ind1_2 + 1).ToString() + "/4";
            msgs[1] = "角一";
            msgs[2] = (ind2_2 + 1).ToString() + "/4";
            msgs[3] = "角二";
            msgs[4] = (ind3_2 + 1).ToString() + "/4";
            msgs[5] = "角三";
            msgs[6] = (ind4_2 + 1).ToString() + "/4";
            msgs[7] = "角四";
            msgs[8] = "职业绩效";
            msgs[9] = "综合完成分";
            msgs[10] = corer5score[2].ToString();
            //装调组
            DrawHuaxiang(new Color[] {
                keyValuePairs[ind1_2],
                keyValuePairs[ind2_2] ,
                keyValuePairs[ind3_2] ,
                keyValuePairs[ind4_2] ,
                keyValuePairs[ind5_2] ,}, xoffset + 250 * 2, yoffset, msgs);

            //验证组的四个顶角排名，与角中的分数
            msgs[0] = (ind1_3 + 1).ToString() + "/4";
            msgs[1] = "角一";
            msgs[2] = (ind2_3 + 1).ToString() + "/4";
            msgs[3] = "角二";
            msgs[4] = (ind3_3 + 1).ToString() + "/4";
            msgs[5] = "角三";
            msgs[6] = (ind4_3 + 1).ToString() + "/4";
            msgs[7] = "角四";
            msgs[8] = "职业绩效";
            msgs[9] = "综合完成分";
            msgs[10] = corer5score[3].ToString();
            //验证组
            DrawHuaxiang(new Color[] {
                keyValuePairs[ind1_3],
                keyValuePairs[ind2_3],
                keyValuePairs[ind3_3],
                keyValuePairs[ind4_3],
                keyValuePairs[ind5_3]},
                xoffset + 250 * 3, yoffset, msgs);
            DrawGroupName("需求组", xoffset + 250 * 0, yoffset);
            DrawGroupName("方案组", xoffset + 250 * 1, yoffset);
            DrawGroupName("装调组", xoffset + 250 * 2, yoffset);
            DrawGroupName("验证组", xoffset + 250 * 3, yoffset);
        }

        private void DrawHuaxiang(Color[] color,int xoffset,int yoffset,string[] toshowstr)
        {
            string testmsg1 = toshowstr[0] +"\n" + toshowstr[1];
            string testmsg2 = "       " + toshowstr[2] + "\n" + "       " + toshowstr[3];
            string testmsg3 = "\n\n\n\n\n"+toshowstr[4]+ "\n" + toshowstr[5];
            string testmsg4 = "\n\n\n\n\n"+"       "+toshowstr[6]+"\n       "+toshowstr[7];
            string testmsg5 = "\n\n\n\n\n\n        "+toshowstr[8] +"\n        "+toshowstr[9]+"\n        "+toshowstr[10];

            DrawTriangle(color[0], 
                new PointF(xoffset,yoffset), 
                new PointF(xoffset, 200 + yoffset), 
                new PointF(100 + xoffset,   yoffset),
                testmsg1);
            DrawTriangle(color[1], 
                new PointF(100 + xoffset,yoffset), 
                new PointF(200 + xoffset,  yoffset), 
                new PointF(200 + xoffset, 200 + yoffset),
                testmsg2);
            DrawTriangle(color[2], 
                new PointF(xoffset,yoffset+200), 
                new PointF(xoffset, 400 + yoffset), 
                new PointF(100 + xoffset, 400+  yoffset),
                testmsg3);
            DrawTriangle(color[3], 
                new PointF(xoffset+200,yoffset+200), 
                new PointF(xoffset+200, 200 +200+ yoffset), 
                new PointF(100 + xoffset, 200+200  +yoffset),
                testmsg4);
            
            DrawSquare(color[4], 
                new PointF(100 + xoffset,yoffset),
                new PointF(xoffset, 200 + yoffset),
                new PointF(100 + xoffset, 400 + yoffset),
                new PointF(200 + xoffset, yoffset + 200),
                new PointF(100 + xoffset, yoffset),
                testmsg5);
        }
         
        private void DrawSquare(Color color, PointF cor1, PointF cor2, PointF cor3,PointF cor4,PointF cor5,string words)
        {
            PointF[] point = new PointF[5];
            point[0] = cor1;
            point[1] = cor2;
            point[2] = cor3;
            point[3] = cor4;
            point[4] = cor5;

            int xmin = new int[] {(int)cor1.X,(int)cor2.X,(int)cor3.X,(int)cor4.X,(int)cor5.X}.Min();
            int ymin = new int[] {(int)cor1.Y,(int)cor2.Y,(int)cor3.Y,(int)cor4.Y,(int)cor5.Y}.Min();
            int xmax = new int[] {(int)cor1.X,(int)cor2.X,(int)cor3.X,(int)cor4.X,(int)cor5.X}.Max();
            int ymax = new int[] {(int)cor1.Y,(int)cor2.Y,(int)cor3.Y,(int)cor4.Y,(int)cor5.X}.Max();
            int width = Math.Abs(xmin - xmax);
            int height = Math.Abs(ymin - ymax);
            Rectangle rec = new Rectangle(xmin, ymin, width, height);
            var g = this.CreateGraphics();
            g.FillPolygon(new SolidBrush(color), point);
            g.DrawString(words, new Font("微软雅黑", 15), Brushes.White, rec);
        }
        protected override void OnPaintBackground(PaintEventArgs e)
        {
            base.OnPaintBackground(e);
            
        }
        private void DrawTriangle(Color color,PointF cor1,PointF cor2,PointF cor3,string words)
        {
            PointF[] point = new PointF[3];
            point[0] = cor1;
            point[1] = cor2;
            point[2] = cor3;
            int xmin = new int[] { (int)(cor1.X), (int)(cor2.X),(int)(cor3.X)}.Min();
            int ymin = new int[] { (int)(cor1.Y), (int)(cor2.Y),(int)(cor3.Y)}.Min();
            int xmax = new int[] { (int)(cor1.X), (int)(cor2.X),(int)(cor3.X)}.Max();
            int ymax = new int[] { (int)(cor1.Y), (int)(cor2.Y),(int)(cor3.Y)}.Max();
            Rectangle rec = new Rectangle(xmin, ymin, Math.Abs(xmax - xmin), Math.Abs(ymax - ymin));
            var g = this.CreateGraphics();
            g.FillPolygon(new SolidBrush(color), point);
            g.DrawString(words,new Font("微软雅黑",15),Brushes.White, rec);
            g.DrawLine(new Pen(Brushes.White), cor1.X, cor1.Y, cor2.X, cor2.Y);
            g.DrawLine(new Pen(Brushes.White), cor1.X, cor1.Y, cor3.X, cor3.Y);
            g.DrawLine(new Pen(Brushes.White), cor2.X, cor2.Y, cor3.X, cor3.Y);
        }
        private void BackgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            //invokeMethod = new ShowUIMSG(UpdateUI);
            //this.Invoke(invokeMethod, xout, yout);
            //MessageBox.Show(string.Format("“{0}”,“{1}”",xout,yout));
        }

        private void BackgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            var val = e.ProgressPercentage;
        }
        
        private void BackgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            
            
            backgroundWorker1.ReportProgress(100);
        }

        private void Option1_ExecProcess(
                                        out string corroted_x, 
                                        out string corroted_y,
                                        string rotpara = "0" ,
                                        string radiuspara = "40",
                                        string xcorpara = "0",
                                        string ycorpara = "0")
        {
            corroted_x = "";
            corroted_y = "";
            //Stopwatch sw = new Stopwatch();
            //sw.Reset();
            //sw.Start();
            // 1) Create Process Info
            var psi = new ProcessStartInfo();
            psi.FileName = @"C:\Users\Administrator\AppData\Local\Programs\Python\Python38-32\python.exe";

            // 2) Provide script and arguments
            var script = @"dotrotate.py";
            var rot = rotpara;
            var radius = radiuspara;
            var xcor = xcorpara;
            var ycor = ycorpara;

            psi.Arguments = $"\"{script}\" \"{rot}\" \"{radius}\" \"{xcor}\" \"{ycor}\"";

            // 3) Process configuration
            psi.UseShellExecute = false;
            psi.CreateNoWindow = true;
            psi.RedirectStandardOutput = true;
            psi.RedirectStandardError = true;

            // 4) Execute process and get output
            var errors = "";
            var results = "";
            using (var process = Process.Start(psi))
            {
                errors = process.StandardError.ReadToEnd();
                results = process.StandardOutput.ReadToEnd();
            }
            //MessageBox.Show(string.Format("{0}{1}", errors,results));
            var finalstr = string.Join(" ", results.Trim().Split(new char[] { '[', ']', ',', ' ' })).Trim();    
        }

        private void FormXueye_Load(object sender, EventArgs e)
        {
            
            

        }

        private void FormXueye_MouseMove_1(object sender, MouseEventArgs e)
        {

        }

        private void label4_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void label2_Click(object sender, EventArgs e)
        {
            detaiFrm detaifm = new detaiFrm(this, this.Choice);
            detaifm.Show();
        }
    }
}
